package cn.itcalvin.sncoal.cth.pojo.response.pf;

import cn.itcalvin.sncoal.cth.config.BigDecimalSerialize;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@Data
public class RespPfListSystem {
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long systemId;

    private String systemName;

    /**
     * 自评状态
     */
    private Integer zpState;
    private Integer hyState;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyTime;

    @ApiModelProperty(value = "自评得分")
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal pfScore;
    private BigDecimal pfScoreZz;
    private BigDecimal pfScoreWeight;


    @ApiModelProperty(value = "自评业务人员")
    private String pfPerson;

    @ApiModelProperty(value = "核验业务人员")
    private String hyPerson;
    @ApiModelProperty(value = "核验得分")
    @JsonSerialize(using = BigDecimalSerialize.class)
    private BigDecimal hyScore;
    private BigDecimal hyScoreZz;
    private BigDecimal hyScoreWeight;


    @ApiModelProperty(value = "自评凭证文件的url地址")
    private String zpRemark;

    @ApiModelProperty(value = "权重")
    private BigDecimal weight;

    @ApiModelProperty(value = "总分")
    private BigDecimal totalScore;

    @ApiModelProperty(value = "任务类型")
    private Integer taskType;


    public  BigDecimal getPfScoreZz(){
        if(systemName.contains("掘进")){
            if(pfScore==null||pfScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return pfScore.setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getHyScoreZz(){
        if(systemName.contains("掘进")){
            if(hyScore==null||hyScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return hyScore.setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getPfScoreWeight(){
        if(systemName.contains("掘进")){
            if(pfScore==null||pfScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(weight).multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return pfScore.multiply(weight).setScale(2, RoundingMode.HALF_UP);
    }

    public  BigDecimal getHyScoreWeight(){
        if(systemName.contains("掘进")){
            if(hyScore==null||hyScore.compareTo(BigDecimal.ZERO)==0){
                return totalScore.multiply(weight).multiply(new BigDecimal(0.6)).setScale(2, RoundingMode.HALF_UP);
            }
        }
        return hyScore.multiply(weight).setScale(2, RoundingMode.HALF_UP);
    }
}
